define(function (require, exports, module) {

    //require('qd-common');
//检测类
	var Auth = require('qd-auth-1.0');
	//AJAX请求类
	var Ajax = require('extendModel/AjaxReturn');
    var signHtml = '{{{signLottery signStatus}}}';

    //判断用户验证信息
    var tpl_info = require('../../tpl/member/main_info.tpl');
    Ajax.ajaxWithHandlebar("/member/investIdentify.html?randomTime=" + (new Date()).getTime(),tpl_info,$(".account_home_msg"),{isAppend:true});

    //收益、余额等信息
    $.ajax({
        type: "post",
        url: "/member/investHandleMoney.html?randomTime=" + (new Date()).getTime(),
        dataType: "json",
        cache: false,
        success: function (json) {
            $(".account_home").html(Handlebars.compile(require("../../tpl/member/main_account.tpl"))(json));
            //提示效果
            require.async(['/plugins/poshytip/tip-yellowsimple/tip-yellowsimple.css','/plugins/poshytip/jquery.poshytip.min'],function(){
	            $('.textTips').poshytip({
	                className: 'tip-yellowsimple',
	                showTimeout: 1,
	                alignTo: 'target',
	                alignX: 'center',
	                alignY: 'top',
	                offsetY: 10,
	                allowTipHover: false
	            });
            });
        }
    });

    //关闭开能第三方账户条
    $(".close").click(function () {
        $(".noAuthentication").hide();
    })

    //首页Tab标签
    require.async('common1', function () {
        $(".account_home_con").tabChange({
            isClick: true,
            isHover: false,
            childLi: "ul li",//tab选项卡
            childContent: ".con",//tab内容
            hoverClassName: "hover",//选中当前选项卡的样式
            callBack: false
        });
    });

    //可投借款
    var tpl_invest = require('../../tpl/member/main_invest.tpl');
    Ajax.ajaxPacket('/member/investList.html','get',tpl_invest,'#main_invest');

    //收款信息
    var tpl_collection = require('../../tpl/member/main_collection.tpl');
    Ajax.ajaxPacket('/member/investCollectionList.html','get',tpl_collection,'#main_collection');
    
    //交易记录 
    var tpl_trade = require('../../tpl/member/main_trade.tpl');
    Ajax.ajaxPacket('/member/investTransactionLog.html','get',tpl_trade,'#tradeLogTable');
    

    $("#jianhao").click(function () {
        $(".noAuthentication").hide();
    });
    //判断用户是否签到
    /*getSignStatus();
    function getSignStatus() {
        $.ajax({
            type: "get",
            url: "/user/getSignStatus.html?randomTime=" + (new Date()).getTime(),
            dataType: "json",
            cache: false,
            success: function (json) {
                $(".qd_account_cj").replaceWith(Handlebars.compile(signHtml)(json));
                //提示效果
                require.async(['tip-yellow-css', 'tip'], function () {
                    $('.textTips').poshytip({
                        className: 'tip-yellowsimple',
                        showTimeout: 1,
                        alignTo: 'target',
                        alignX: 'center',
                        alignY: 'top',
                        offsetY: 10,
                        allowTipHover: false
                    });
                });
            }
        });
    }*/

    //用户签到动作
    $(".qd_account_cj_w").live("click", function () {
        $.ajax({
            type: "post",
            url: "/user/doSign.html?randomTime=" + (new Date()).getTime(),
            dataType: 'json',
            cache: false,
            success: function (json) {
                //单点登录检测
                if(Auth.checkLogin(arguments[0]) == false) {return ;}
                if (json.result) {
                    //收益、余额等信息
                    $.ajax({
                        type: "post",
                        url: "/user/getSignStatus.html?randomTime=" + (new Date()).getTime(),
                        dataType: "json",
                        cache: false,
                        success: function (json) {
                        	$(".qd_account_cj").replaceWith(Handlebars.compile(signHtml)(json));
                            //提示效果
                            $('.textTips').poshytip({
                                className: 'tip-yellowsimple',
                                showTimeout: 1,
                                alignTo: 'target',
                                alignX: 'center',
                                alignY: 'top',
                                offsetY: 10,
                                allowTipHover: false
                            });
                            window.location = "/member/signLottery.html";
                        }
                    });
                }
            }
        });
    });
});

